// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var validate = require("validate");
	var dialog = require("dialog");
	var topMenu = require("../topMenu/topMenu");
	var databind = require("databind");
	var css_personal_info = require("./personalInfo.css");
	var init = function() {
		topMenu.init();
		$(".table-section").removeClass("none");
		$(".footer").removeClass("none");
		initEvent();
		loadData();
	};
	var loadData = function() {
		$("#personalInfo").find(".field-input-empCode").attr("readonly", "readonly");
		databind.fillInput($("#personalInfo"), {
			action: "inquireCurrentAccountEmployeeInfo.json",
			version: "v3.0"
		});

	};
	var initEvent = function() {
		//若未登录，则返回登陆页面
		if (base.getData("sid") == null || base.getData("sid") == "" || base.getData("sid") == undefined) {
			location.href = "../../../platform/login/login.html";
		}
		$("#personalInfo").on("click", ".button-back", function() {
			window.history.go(-1);
		});

		$("#personalInfo").on("click", ".button-submit", function() {
			databind.enableInput($("#personalInfo"));
			var promptString = validate.isPhone($("#persionalInfoPhone"), "请输入正确的手机号！");
			var promptString1 = validate.isEmail($("#persionalInfoEmail"), "请输入正确的电子邮箱！");
			if (promptString != "") {
				util.alert(promptString);
			} else if(promptString1 != ""){
				util.alert(promptString1);
			} else {
				databind.submitDom($("#personalInfo"), message());
			}
		});
	};

	var message = function() {
		base.alert(1, "修改个人信息成功");
	}
	return {
		init: init
	};
});